RAPIDQ
Object orientated Programming Language
Created and Edited by Learron Ashton
Please check out http://rapidq.no-ip.org for FREE bannerless 150 MB Web hosting
Please note that Spelling mistake and omissions are NOT intentional and email me at the above address if there are any mistakes
Please also note that
ALL source code can be downloaded from the Tutorials Site and also can be
shipped for $
Let’s start of with a simple program, the famous
hello world application.
Enter this line into the
RapidQ Code Viewer
Go to the file menu and
choose save, save it as the filename helloworld.bas
From the run menu choose
run or simply hit F5 and you will see the following
Click on the OK button to
close the window
You will notice the Menu
bar of the top Program says helloworld, It will default to the Filename, we can
change this by adding the following line above the line we added before
application.title="Test Application" we see the following
We cannot see the whole
Title because it is too long for the Minimum size of a Form.
The only way to see the
whole title is to make the Test longer so change the following line
Showmessage “hello
world” to
Showmessage “ hello world
” notice how there are 10
blank spaces before and after the text hello world
Press F5 and you get the
following
The above is our first
application, save it and call it hello world app.bas
Go to the Window menu and
click Form1
and you will see the
following:
The above Window is what we
call a FORM, a FORM is something similar to a Piece of canvas, we can add
buttons and other controls to this form, of which we will do as we get along in
this book.
On the above form click the
Button button (I know I know) click on this
and click on the form somewhere like this
Click once on the button so
it looks like this
The left are the
properties of this Button, we will run through these on the Next page, each
property has an effect on the Button
On the Left hand side you
will see this
To change options click on the relevant option and you
will see of these these allow you to choose
from a list of options by clicking on the arrow like this: The options are displayed in a list like above, to
select and option highlight it and left click it
If you select 4 –alright
you will see the following
As you can see the Button
has aligned itself to the right hand side and taken up the Whole height of the
form, of course you can resize any object by dragging the little black boxes as
shown below
Okay Now change the
property that says caption to say Hello world so it should look like the
Screen shot on the following page
Now before we proceed I
want to explain something.
On the right of the
Properties Tab is the Events Tab, ()
events are actions that occurs when something is done, now different Objects
have different Events, for example the Button has the following Events:
If you select the Button
now, and click on the Events Tab
and click inside OnClick, a appears, click on this and you will be
presented with the following:
The code inside here will
be executed when the button has an OnClick event, or a user Clicks on the
button
Inside this box enter the
following code
Click on the Code it button
and then save it as Hello
app2.bas
then Run the App (by
pressing F5), you should get, a screen like the one below
Click on the Button now and
you should get
This little dialog box came
up because we said in the box on the previous page Showmessage “Hello again
world” this told the program that when the button was pushed display this code.
ClS – this just clears the
screen in Console Applications, here I will briefly explain the two types of
applications RapidQ can do, GUI or Console, Console are DOS based applications,
they run in a window,
Console Application
A GUI (Graphical user
Interface) Application is like the one(s) that you have been creating.
In a Console Application,
cls clears the screen and print displays text on the screen, Input allows a
user to input stuff, so let’s try out hand at a console application.
Click the new icon to open
up a new window, type the following
print "what is your sex"
Input sex$
if sex$="male" then
print "you are a male"
end if
if sex$="female" then
print "You are a female"
end if
sleep 5
I will explain the above
program:
The first line displays the
text “what is your sex”, the second line says wait for user input, and when
they do type something and press enter
it will be saved in the variable sex$, now I will explain variables.
Variables are like Post
boxes, they hold temporary information, so when you entered male the variable
sex$ also was male, the fact that it had a $ on the end means that Both text
and number can go into it, if it has a $ then it is called a String, a string is
anything that is encased in either “ marks or in NOT a number example
If we enter the following
lines
A$=”1+2”
Sleep 5
If we were to enter the
above, we would just get 1+2 on the screen, then a short delay of 5 seconds,
this can be good if you are wanting to display this equation, however if you
want to find the result we have to take it out of its string form,. Because
being a string it is NOT a number or equation t\for that matter.
Try this
a=1+2
print a
sleep 5
The above code displays 3,
this is Because a is NOT a string, it is still a variable though, and the print
a told RapidQ to print the result, so let’s recap about variables, pick the
strings from the below list:
Var1
Var$
Fish$
Rod$
Fumble
Trick$
The answer to the previous
Quiz was
Var$
Fish$
Rod$
Trick$
Because they ALL have the
$.
Back to the Program we ran
before
print "what is your sex"
Input sex$
if sex$="male" then
print "you are a male"
end if
if sex$="female" then
print "You are a female"
end if
sleep 5
The 3rd line
says if what the user enters and stores in the string variable sex$ equals male
(notice how male is in Quotation marks, this is so it is treated as a string)
then line 4 says print on the screen “you are male”.
Line 5 says end the if
statement, ALL if statements MUST be terminated, as soon as possible (with the
end if command) this is for two reasons:
1) – They can get VERY messy if you don’t
2) – You may actually end up ending the wrong if
statement
I will give you a demonstration
The following program
print "What’s your name (
input name$
if name$="
print "Thats good"
if name$<>"
end if
print "Not good"
end if
sleep 5
Would ask you for your
Name, when you entered
That’s good
Not good
This is because of BAD if
statement termination.
The correct syntax should
be
print "What’s your name (
input name$
if name$="
print "Thats good"
end if
if name$<>"
print "Not good"
end if
sleep 5
Not the above code, but the
code above that was saying if what the user entered was gary then print That’s
good and Print Not good then END the IF statement
Back to the Program
print "what is your sex"
Input sex$
if sex$="male" then
print "you are a male"
end if
if sex$="female" then
print "You are a female"
end if
sleep 5
If the user enters female as the sex then print on the screen You are a female
End the IF statement
The Sleep 5 just pauses the
Application for 5 seconds so you can see the outcome
Check out the
RQDOCS\console.html file
Okay lets make a useful
Application, lets make a database that will allow you to store information
about contacts, sort of like your Windows Address book!
Okay now design your form
similar to the one shown below
Clicking on the Edit button
and then click on the form
Now in there properties
area change the text here
Change the Text so that it
displays nothing (empty the text property)
Change the location of the
edit box by changing the left property to 50 and the top property to 30
Now do the same, place 3
more on the form, align the ALL to left 50 and top multiples of 30, 60, 90, 120
Click on the Label button
and position that at left 180 top 35
and 3 more at left 180 and
top at multiples of 36, 65, 95, 125
it should look like this
Change the caption properties
of the Labels to read:
Label1=Surname
Label2=First Name
Label3=Address
Label4=Phone Number
As you can see the Labels
aren’t quite wide enough, simple solution
Change the width of each to
100
The Updated form should
look like this
Add three button as shown
below by clicking on the Buttons Button and then arranging them with what ever dimensions
you want
Change their text to:
Cancel
<Back
Next >
So that it looks like this
Now click on the Cancel
Button and then click on the Events Tab of the Properties Area and select
Click the … button and you
will get
This is called the Event
handle window, in here enter
End This simply Ends the program if this button is
Clicked.
Click on OK to apply the
settings (you must Always click on OK to apply code settings).
Click on Button 2 “The one
with < Back written on it” and go to the properties tab and change the
enabled property to
0 – false
So the form should look
like this
The Disabled < Back
button now cannot be clicked.
Click on the Next >
button and go to the events tab and enter an event at OnClick (click on the …
button) and enter into the Event handle Box the following code (of which I will
explain)
DIM data as qfilestream
data.open("c:\data.txt",
65535)
data.writeline(edit1.text+"|"+edit2.text+"|"+edit3.text+"|"+edit4.text)
The above text is only a
portion of it so I will explain this first.
The DIM data as qfilestream
means basically set up the variable data as a file handler (this means
everything the data refers to will be the file)
data.open("c:\data.txt",
65535)
The above line means (using
the file handler data) data.open means open then file that data handler refers
to in this case c:\data.txt
The filename quoted in “”s
means this is the file to open, note you NEED to use the Full Resource locater
(RL) the part of the file that says ,65535 means to Create the file, the modes
are as bellows:
To create a file = 65535
To open a file for reading
ONLY = 0
To open a file for Writing
ONLY = 1
To Open a file for Read and
Write = 2
So if you are writing to or
reading from use 2, IMPORTANT NOTE When you use
mode 65535 be careful, next time you use this and you ask the file to be
created again (by using 65535) and the file already exists then you are going
to run into problems, if in a program you have a file created all the time then
you must delete the file prior to creating it!
data.writeline(edit1.text+"|"+edit2.text+"|"+edit3.text+"|"+edit4.text
The above line says write a
line of something to c:\data.txt.
So the above line says to
write edit1.text+"|"+edit2.text+"|"+edit3.text+"|"+edit4.text
to the data.txt.
The above line is saying
what ever is held in the edit filed edit1.text, edit2.text, edit3.text and
edit4.text to the data file.
Note in the above screen
shot I have added the line data.close
The above line tells RapidQ
to close the file with the handle of data (in this case c:\data.txt).
This then means that the
file is closed, you can now use the handle data and you don’t have to declare
it because it has already been declared in the line that we discussed ages ago DIM
data as qfilestream.
Now that we have the form
designed and the basics on the Code written, we have to do a few more little
things, we have to enable the Back button when the Next > button is clicked.
Add the code into the event
handler box under the line data.close
button2.enabled = 1
so when the Next >
button is clicked the button2 will become active, in this example this is the
back button, now we must give the illusion that the < Back button actually
does go back, with this we must click OK to accept the code in the
button1.click event handler, and then click on the < Back button click on
the events tab and open up an onclick event handler for the < Back button.
To open up the event
handler click on the back button
and then click on the
Then click on the onclick
event tab
now click on the … button
you will get the following
In here erase the line
above (this is put in automatically) and put the following text in
edit1.text=""
edit2.text=""
edit3.text=""
edit4.text=""
button2.enabled=0
The above line(s) say in
the edit1.text filed put nothing (clear it) do the same with edit2.text,
edit3.text and edit4.text.
When the four fields are
cleared then disable the < Back button again, the reason why we have done
the above code, is to give the appearance that the Back button has gone back to
the previous screen, which of course we know hasn’t happened.
Be very careful when ding
this with your programs, you will need to initialize ALL variables, for example
if we had a variable called tt in the code somewhere and ran the program like
this, the tt variable will still hold what ever it was holding when it was last
called, this can be particularly dangerous in loops, for example if we had a
loop that ran 100 times, then when the back button was Clicked, and we were
using tt to count the number of times, so when tt was the value of 100 it would
stop, we would be in trouble because tt is already set to 100 so the loop would
NOT run, so here's the first EXTEREMELY important rule
Always
reset variables, and before
They are
used ALWAYS set them
to their
starting value.
You should have the
following code, it is also in the code\app1 directory on the CDROM
' Copy and paste into your
program
DECLARE SUB Button1Click (Sender AS QBUTTON)
DECLARE SUB Button2Click (Sender AS QBUTTON)
DECLARE SUB Button3Click (Sender AS QBUTTON)
CREATE
Caption = "Form1"
Width = 428
Height = 293
Center
CREATE Label1 AS QLABEL
Caption = "Surname"
Left = 180
Top = 35
Width = 42
END CREATE
CREATE Label2 AS QLABEL
Caption = "Firstname"
Left = 180
Top = 65
Width = 45
END CREATE
CREATE Label3 AS QLABEL
Caption = "Address"
Left = 180
Top = 95
Width = 38
END CREATE
CREATE Label4 AS QLABEL
Caption = "Phone Number"
Left = 180
Top = 125
Width = 71
END CREATE
CREATE Edit1 AS QEDIT
Text = ""
Left = 50
Top = 30
END CREATE
CREATE Edit2 AS QEDIT
Text = ""
Left = 50
Top = 60
TabOrder = 1
END CREATE
CREATE Edit3 AS QEDIT
Text = ""
Left = 50
Top = 90
TabOrder = 2
END CREATE
CREATE Edit4 AS QEDIT
Text = ""
Left = 50
Top = 120
TabOrder = 3
END CREATE
CREATE Button1 AS QBUTTON
Caption = "Next >"
Left = 322
Top = 223
TabOrder = 4
OnClick = Button1Click
END CREATE
CREATE Button2 AS QBUTTON
Caption = "< Back"
Left = 234
Top = 223
Enabled = 0
TabOrder = 5
OnClick = Button2Click
END CREATE
CREATE Button3 AS QBUTTON
Caption = "Cancel"
Left = 18
Top = 223
TabOrder = 6
OnClick = Button3Click
END CREATE
END CREATE
'Insert your initialization
code here
Form.ShowModal
'--------- Subroutines
---------
SUB Button1Click (Sender AS QBUTTON)
DIM data as qfilestream
data.open("c:\data.txt",
65535)
data.writeline(edit1.text+"|"+edit2.text+"|"+edit3.text+"|"+edit4.text)
data.close
button2.enabled = 1
END SUB
SUB Button2Click (Sender AS QBUTTON)
edit1.text=""
edit2.text=""
edit3.text=""
edit4.text=""
button2.enabled=0
END SUB
SUB Button3Click (Sender AS QBUTTON)
end
END SUB
Normally I will not show
code here in this book as it takes up too much space but here we need to do
some tidying up, remove the line that start with the ‘ key
E.g. the following line(s)
'---------
Subroutines ---------
'Insert
your initialization code here
'
Copy and paste into your program
Theses will typically
appear in Green italics but not always, these lines take up space in the
application (not much) but it makes the code smaller.
Under the FORM code change
the following line Caption =
"Form1"
Change the word(s) Form 1
to what ever you want, try Database application V1.0.
Save the File and run it
you will get the following Finished application
when you look in the root
directory of your C Drive you get a file called data.txt open it and you get.
The problem with this application is two fold, one we
need to change the file opening mode to 2, not 65535 because the file already
exists we don’t want to delete it then recreate it, because it hold data that
we want to keep, so change the Mode to 2, so change the line above that says:
Data.open(“c:\data.txt”,
65535) to
Data.open(“c:\data.txt”, 2)
to
Also we don’t want the Text
to be replaced every time we enter a new entry so just before the line where it
says data.writeline …
Enter data.seek(0,2)
This will cause new Data to
start at the end of the file!
This is the end the
application runs fine
The code is on the CDROM
under the code app1 directory under the file version 2.bas
The Application actually
works and can be used, feel free to change it, oh yeah and you can sell the
application if you want for a fee.
Variables
Now we learn some
fundamentals?
Variables are little boxes
of information that hold data, for example the variable dta=18
This means that the
Variable data holds the value 18, now variables can be practically any length
and contain any characters and/or number as long as strings (these are
Variables that end is the $ sing) contain at least 1 letter.
So if we were to type
Dta$=”18”
showmessage dta$
then we would get
Now the $ means that it
holds Text, although in this example we have a number
Strings can hold either
Numbers and/or Text so lets recap, strings are collections of text, variables
can hold strings, note that numbers can also be text, when a number is held as
a string it cannot be added for example:
A$=”123”
B$=”456”
Showmessage a$+b$
The above code would show
so to covert the above code
into a mathematical operation we need to change the strings to numeric
variables, abc we do this by the Val command
a=Val("123")
b=Val("456")
c=a+b
Showmessage str$(c)
Note above the first
line says assign the variable a the number 123 and assign the variable b to
456, the third line says assign the variable c the equation 123+456, the
following line after that says to display the answer held in c as a string,
note the showmessage command can ONLY show strings, so the str$() command
converts Numbers into strings.
So Val()
converts from strings to numbers and Str$() converts from numbers to strings,
note Val() will NOT convert a Strings like a$=”aaa” to a number!
Strings can
hold an infinite number of characters for example:
Name$ = “this
is my name bob jones”
Printing the
above command would show
Enabling and Disabling
Components
Create a Form similar to
the following form, it does not have to be exact
What we are going to do it
when you click on checkbox 1 button 1 is disabled and when checkbox 2 is
clicked button 2 disables and button 1 enables and so on…
Try this code
First create a on click
event for the checkbox1 (when I say for example an onclick event for the
checkbox1, I mean click on the component checkbox1 and then click on events,
then click OnClick)
In the above box add then
following
button1.enabled = 1
button2.enabled = 0
and click ok then click on
the checkbox2 component and create an onclick event and enter the following
button2.enabled = 1
button1.enabled = 0
Now code the form and run
it (when ever you code new forms you may need to save it, this code is included
on the cdrom as cbenabler when you run it and click on checkbox1 button1
becomes disabled and when you click on checkbox2 button 2 becomes disabled,
this was possible because when a user clicked on checkbox1,. We said to enable
a button e.g. buttin1.enabled and disable the other button e.g.
button2.disabled, you have got to remember in this example when you have 2
components working like we have in the previous example, when you are enabling
one to disable the other.
Component fun
Let’s start having some fun
with the different components
Make the above Form.
We are going to do some fun
stuff with this form, the first thing I want to do it make the form display Hello
world in the edit box when the Round button (OvalBtn1) is pressed, so create an
Onclick event for OvalBtn1
In the Event handler box
enter
edit1.text="hello
World"
Now code is save the form
and run it and clicking on the Oval button will display Hello world in the Edit
box like below
Now I want the Radio Button
the have a dot in the circle to it immediate left, to do this we must edit the
Onclick event for the Oval button and add
radiobutton1.checked=1
under the already existing
code.
When the user clicks on
checkbox1 we want a messagebox to display “Yeahh”
This should be simple for
you now, create an OnClick event for the checkbox1 component and in the event
handler box enter
showmessage
"Yeahh"
Now what we want to do is
when the radiobutton1 radiobox is checked (or got a dot in the circle) the
message yeahh is displayed but we don’t want the checkbox1 checked, what we can
do is rather than rewrite the code for the radio button is activate the
checkbox then de activate the checkbox1, try this code by creating an Onclick
event for the radiobutton1
checkbox1.checked=1
checkbox1.checked=0
Now what this will do is
remember when we made the checkbox1 activate when the oval button is pressed,
what this will do is, when the user click on either the radiobutton1 Or the
Ovalbutton1 the message “yeahh” is displayed (this was all planned)
Now I know that the above
example form is absolutely useless so let’s make a useful application, let me
think hmmmm…
Lets create a little Game,
that allow someone to enter a number if the number is under 5 then the program
will not allow you to click the Show button, but if the number is 5 or above it
will, try creating the form shown below
Now create an OnClick event
for the
… Button and add the following
if edit1.text="4"
or edit1.text = "3" or edit1.text = "2" or edit1.text =
"1" or edit1.text = "0" then
button1.enabled=0
else
button1.enabled=1
end if
in the Show Button enter an
Onclick event that contains the following cod
Showmessage
"Thankyou"
When running this Game, if
you enter below 4 i.e. 4,3,2,1 or 0 then Show button becomes disabled this is
called error checking, and 5 or above the button is enabled.
Assessment 1
Create a Game that the
computer thinks of a number between 1 and 9 using the following lines
Randomize timer
Compnum=int(rnd(1)*9)
To generate the random
number and using the below form
Now the user enters their
number into the edit box and when then click on Guess a message box pops up
saying “Higher” if the users number is higher than the number the computer
guessed or “Lower” if the users number is lower than the number that the
Computer guess, and it displays “TES” when both computer and users number are
the same!
The code is as follows, the
Bold statements describe this program
' Copy and paste
into your program
DECLARE SUB Button1Click
(Sender AS QBUTTON)
randomize timer this
makes the random number different
compnum=int(rnd(9))
This is the random number
CREATE
Caption = "Form4"
Width = 320
Height = 240
Center
CREATE Label1 AS QLABEL
Caption = "Enter a Number between
1 and 9"
Left = 48
Top = 18
Width = 160
Transparent = 1
END CREATE
CREATE Label2 AS QLABEL
Caption = "Label2"
Left = 62
Top = 144
Width = 112
Transparent = 1
END CREATE
CREATE Edit1 AS QEDIT
Text = "Edit1"
Left = 70
Top = 41
END CREATE
CREATE Button1 AS QBUTTON
Caption = "Guess"
Left = 97
Top = 73
TabOrder = 1
OnClick = Button1Click
END CREATE
END CREATE
'Insert your
initialization code here
Form.ShowModal
'---------
Subroutines ---------
SUB Button1Click
(Sender AS QBUTTON)
label2.caption="Number
is "+str$(compnum) This displays the random number, you can lave this
line out if you want
if
editbox1.text="9" or editbox1.text="8" or
editbox1.text="7" or editbox1.text="6" or
editbox1.text="5" or editbox1.text="4" or
editbox1.text="3" or editbox1.text="2" or editbox1.text="1"
or
editbox1.text="0" then this line checks that the number is 1 to 9
button1.enabled=1
else
showmessage
“Come on between 1 and 9” tells the user they haven’t chosen a number
between 1 and 9
end if
humnum=Val(edit1.text)
if compnum=humnum then the 2 numbers are the same
showmessage "YES"
end
end if
if
compnum<humnum then the
2 numbers are not the same
showmessage
"Lower"
else the only other check
possible is the computer number is higher than the human number
showmessage
"Higher"
end if
button1.enabled=1
END SUB
File operations
Now we are going to learn
about file operations, this is important because with this you can change the
contents of a file.
Now before we continue we
are going to use a file that was included on the CDROM, so copy the file called
data.txt to a directory and remember cause we are going to be using it.
The first thin we do for a
file is set it up for operations first you need to write
DIM file as qfilestream
now the word file could be
anything this is just to identify the file, the next line is
File.open(“c:\data.txt”, 2)
This gets the file open
ready for read and write, 65535 sets the file up to be created, be careful
though the program will NOT go past the line with 65535 if the file already
exists.
Now we have the file initialized
and open for read/write operations w are going to be able to have some fun with
the file.
Now to add a line to the
file we need to add file.writeline(“tony”)
file.writeline(“7852-3658”)
This is fine but the
problem is the information would overwrite what’s already in the file data.txt,
so to get to the end we need to add
file.seek(0,2)
Now when ever we use the
above line data will be appended to the end of the file instead the front.
Rapidq.inc stipulates how
these work they work by the way of the following:
0 = from the beginning
1 = From the current
2 = from the end
so file.seek(1,2) would be
from the current to the beginning, remembering that seek means got from
somewhere (being one of those numbers ) to somewhere else (being the second number)
file.eof is useful for when
we want to get the end of the file, so your code should like this now
DIM file as qfilestream
File.Open("c:\data.txt", 2)
file.seek(0,2)
file.writeline("tony")
file.writeline("7852-3658")
After running the previous
code check the file and make sure the data is entered
Now I am going to introduce
to you the fun of EOF.
For this exercise we are
going to use the same file but we are going to ready each line of code from the
file and then we are going to end the code with the EOF function
Check out this code
DIM file as qfilestream
File.Open("c:\data.txt",
2)
do
data$=file.readline
showmessage data$
loop until file.eof
The first two lines are
self explanatory but I will explain it again, the first line initializes the
file, and creates a filestream, the second line opens the file ready for both
read and write access, to 3rd line is where the loop starts (we go
through loops next) and the 4th line we have the line
data$=file.readline
This line assigns any
information contained in the file Line by line to the variable Data$.
The line that follows that
is just to show what is contained with the data$ variable and of course
loop until file.eof
the above line says loop
the contents between the words Do and Loop until we reach the end of the file
Note file.eof means until
the end of file is reached.
The other useful ones that
you’ll use are linecount
So we are going to add the
line
Showmessage
str$(file.linecount)
Now the above line
basically displays the message (via messagebox command) the number of lines
(via the linecount command) now because this is a number we have to copnvert6
it to a string, as the message command will NOT display true numbers, but only
numbers treated as strings, if we wanted the number of lines to stay as a
number then we would have to use just file.linecount
The line file.size tells us
the files size, so change the line
Showmessage
str$(file.linecount)
to
Showmessage str$(file.size)
And it may show something
like
This just happens to be the
size of my data.txt file
Now we have discussed
file.writeline, there is also file.writestr(string,size) e.g.
File.writestr(“hello”,5)
then size has to be the number of characters
Working with Variables
Okay now Variable come in
two flavors they are Strings and Numbers, an example of a string variable is
varstring$, a number variable is varnumber!
Now number Variable can be
strings by changing varnumber to varnumber$.
Now you cannot add 1 + 1
and get 2 if the two numbers are variables adding “1” + “1” (note we enclose
strings in quotation marks) will get you “11”, but two numbers variables will
give you 2
So you will have to think
carefully about variables, lets try a little program with variables
Try this code
a$="1"
b$="3"
showmessage "a$ + b$ = "+a$+b$
'now converting the strings to number
variables
a=Val(a$)
b=Val(b$)
showmessage "a + b = "+str$(a+b)
the first and second lines
set a$ to be the string 1 and b$ to be the string 3.
Then a message is shown
like the one below
The 4th and 5th
lines are a comment, on the 6th line we convert the string to a
number using the Val() command and assign the NEW value of 1 to a and the NEW
value of 3 to b then we add them together and show the answer, BUT we must
convert the numbers to a String again using the str() command in order for the
Program to show the numbers, so we get the following as the second screen.
So we can see how 1+3=4 and
how “1” + “3” = “13”.
Unlike other Programming
languages rapidq does NOT need the variables initialized
Loops
There are 2 types of loops,
the conditional and un-conditional.
The conditional is a loop
that will stop when a condition is reached, an un-conditional loop is one that
will go for ever until a user breaks out of it, I dunno why you would want an
un-conditional loop but hey they do exist, let’s sort out a conditional loop
do
c=c+1
showmessage "looping "+str$(c)+" times of 10"
loop until c=10
The above loop shows a
conditional loop the condition of this loop is in the line loop until c=10, which
means when the variable c reached 10 it would stop.
Take a look at this loop
for i=1 to 10
showmessage "looping "+str$(i)+" times of 10"
next i
The above loop does the
exact same as the loop before so what is the difference
Well the two loops are identical
in their form, lets say we wanted the second example to loop from 3-7 we would
change it to
for i=3to 7
showmessage "looping "+str$(i)+" times of 10"
next i
The First example would
appear like this
c=3
do
c=c+1
showmessage "looping "+str$(c)+" times of 10"
loop until c=7
These 2 loops do the same
also, so it really depends on your preference, there is another loop however
called while wend
while c<10
c=c+1
showmessage "looping "+str$(c)+" times of 10"
wend
more to come…